package code.util;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class CodeGeneratorContext {
	/**
	 * 应用上下文对象
	 */
	private static ApplicationContext context;
	/**
	 * 获得ApplicationContext实例
	 * @return
	 */
	public static ApplicationContext getInstance(){
		if(context == null){
			context = new ClassPathXmlApplicationContext("codeGeneratorContext.xml");
		}
		return context;
	}
	/**
	 * 根据名称获得指定的bean
	 * @param name
	 * @return
	 */
	public static Object getBean(String name){
		return getInstance().getBean(name);
	}
}
